package com.yanqu.road.server.timer;

import com.yanqu.road.server.CrossBaseServer;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.manager.rank.IRankDataMgr;
import com.yanqu.road.utils.executor.GeneralTask;

public class MgrRankDataSaveTask extends GeneralTask {

    @Override
    public void doRun() {
        for (TempMgr baseMgr : CrossBaseServer.getInstance().getMgrList()) {
            if(baseMgr instanceof IRankDataMgr){
                try {
                    long startTime = System.currentTimeMillis();
                    baseMgr.save();
                    long cost = System.currentTimeMillis() - startTime;
                    getLOGGER().info("{} save cost {} mills.", baseMgr.getClass().getSimpleName(),cost);
                } catch (Exception e) {
                    getLOGGER().error("{} save error.", baseMgr.getClass().getSimpleName(), e);
                }
            }
        }
    }
}
